#include"everytest.h"
#include"global.h"
#include"testset.h"
#include"function.h"
#include"FDR.h"
#include"EFDR.h"
#include"VIHC.h"
#include"EVIHC.h"
#include"V9C.h"
#include"testsetXor.h"
//

//main step
double _test(const testset &ts)
{	
	//cout<<"<"<<ts.name()<<">  \t"<<setprecision(4)<<_Ratio<<endl;
	//cout<<"<"<<ts.name()<<">"<<endl;
	//int in_num=static_cast<int>(log(ts.length())/log(2));
	//int order=static_cast<int>(log((ts.length()+(1<<in_num)-1)/(1<<in_num)*ts.num()*2-1)/log(2));
	//int order=static_cast<int>(log(ts.num()*2-1)/log(2));
	//cout<<"[input num]:"<<in_num<<"\t[order]:"<<order<<endl;
	//testsetXor_vertical::choose(*ts.data_reverse(),7);
	//testsetXor_vertical::choose(*ts.data_reverse(),order,in_num);
	//testsetXor_vertical::choose_multi(*ts.data_reverse(),order,in_num);
	//testsetXor_vertical::choose2(*ts.data_reverse(),8);
	//int L=FDR::code(FDR::reorder(ts.data()))->length();
	//int L=FDR::code(*testsetXor_vertical::compress(*ts.data_reverse(),order,in_num))->length();
	//int L=FDR::code(*testsetXor_vertical::compress_multi(*ts.data_reverse(),order,in_num))->length();
	//int L=FDR::code(*testsetXor_vertical::compress(*ts.data_reverse(),order))->length();
	//int L=VIHC::code(*testsetXor_vertical::compress(*ts.data_reverse(),7))->length();
	//int L=V9C::vcode(*testsetXor_vertical::compress(*ts.data_reverse(),7))->length();
	//int L=FDR::code(*testsetXor_vertical::compress_lfsr(*ts.data_reverse(),12))->length();
	//int L=FDR::code(*ts.data_string())->length();
	int L=VIHC::code(*ts.data_string())->length();
	//int L=V9C::code(*ts.data_string())->length();
	//int L=V9C::vcode(*ts.data_string())->length();
	//int L=EFDR::code_dynamic(*ts.data_string())->length();
	double _Ratio=testset::ratio(ts.size(),L);
	//cout<<"[Percentage compression]\t"<<_Ratio<<endl;
	printf("%.2f\n",_Ratio);

	//
/*
	string filename=string("out/")+ts.name()+".nox";
	ofstream out(filename);
	if(!out)throw msg(filename+":cannot open");

	string data=*testsetXor_vertical::compress(*ts.data_reverse(),7);
	for(int i=0;i<ts.num();i++)
		{
		for(int j=0;j<ts.length();j++)
			out<<data.at(i*ts.length()+j);
		out<<endl;
		}
	
	out.close();
*/
	
	//cout<<"---\n\n"<<endl;
	return _Ratio;
	//return 0;
	
}

